import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入对应的样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 导入树状图插件
import TreeTable from 'vue-table-with-tree-grid'
Vue.config.productionTip = false
// 为所有组件设置axios属性
Vue.prototype.$http = axios
axios.defaults.baseURL = 'http://www.ysqorz.top:8888/api/private/v1/'
// 对请求进行拦截 做预处理
axios.interceptors.request.use((config) => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.use(VueQuillEditor)
// 全局注册组件
Vue.component('tree-table', TreeTable)
// 定义一个时间过滤器
Vue.filter('dataFormat', function (time) {
  const date = new Date(time * 1000)
  const y = date.getFullYear()
  const m = ((date.getMonth() + 1) + '').padStart(2, 0)
  const d = (date.getDate() + '').padStart(2, 0)
  const h = (date.getHours() + '').padStart(2, 0)
  const mm = (date.getMinutes() + '').padStart(2, 0)
  const s = (date.getSeconds() + '').padStart(2, 0)
  return `${y}-${m}-${d}-${h}-${mm}-${s}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
